<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Created by IntelliJ IDEA.
 * User: david.hoffer
 * Date: Jan 10, 2010
 * Time: 4:17:03 PM
 */
class ERequestedPayer {
    
    const All = 'Default';
    const Seller = 'Seller';
    const Buyer = 'Buyer';
    const Split50 = 'Split50';
    
    const AllVal = "Default";
    const SellerVal = "Seller Pays";
    const BuyerVal = "Buyer Pays";
    const Split50Val = "50-50 Split";
    

    private $name;

    public function ERequestedPayer($name) {
        $this->name = $name;
    }
    public function __toString() {
        return $this->name;
    }
    public function getValue()
    {
        switch ($this->name)
        {
            case ERequestedPayer::All: 
                return ERequestedPayer::AllVal;
            case ERequestedPayer::Seller: 
                return ERequestedPayer::SellerVal;
            case ERequestedPayer::Buyer: 
                return ERequestedPayer::BuyerVal;
            case ERequestedPayer::Split50: 
                return ERequestedPayer::Split50Val;
            default:
                return ERequestedPayer::AllVal;
        }
    }
    public static function getAllRequestedPayers()
    {
        return array('Default', 'Seller', 'Buyer', 'Split50');
    }
    public static function getAllRequestedPayerValues()
    {
        return array('Default', 'Seller Pays', 'Buyer Pays', '50-50 Split');
    }

    public static function fromDisplayName($name) {

        $allRequestedPayers = $this->getAllRequestedPayers();
        foreach ($allRequestedPayers as $payer)
            if ($name == $payer) {
                return new ERequestedPayer($name);
            }
        
        return null;
    }
}
?>
